<?php

/**
 * Generated Model class.
 */
class Base_UserPeer extends Db_Peer implements ISingleton
{

    const ID = '`user`.`id`';

    const VK_ID = '`user`.`vk_id`';

    const NAME = '`user`.`name`';

    const LAST_NAME = '`user`.`last_name`';

    const GROUPS = '`user`.`groups`';

    const ACCESS_TOKEN = '`user`.`access_token`';

    const CREATED = '`user`.`created`';

    const MODIFIED = '`user`.`modified`';

    const SEX = '`user`.`sex`';

    protected $_name = 'user';

    protected $_rowClass = 'UserRow';

    protected $_dependentTables = array(
        'TurnPostPeer',
        'User2groupPeer'
        );

    protected $_referenceMap = array();

    private static $_instance = null;

    protected $_metadata = array(
        'id' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'id',
            'COLUMN_POSITION' => 1,
            'DATA_TYPE' => 'int',
            'DEFAULT' => null,
            'NULLABLE' => false,
            'LENGTH' => null,
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => true,
            'PRIMARY_POSITION' => 1,
            'IDENTITY' => true
            ),
        'vk_id' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'vk_id',
            'COLUMN_POSITION' => 2,
            'DATA_TYPE' => 'int',
            'DEFAULT' => null,
            'NULLABLE' => false,
            'LENGTH' => null,
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => true,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'name' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'name',
            'COLUMN_POSITION' => 3,
            'DATA_TYPE' => 'varchar',
            'DEFAULT' => null,
            'NULLABLE' => false,
            'LENGTH' => '30',
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'last_name' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'last_name',
            'COLUMN_POSITION' => 4,
            'DATA_TYPE' => 'varchar',
            'DEFAULT' => null,
            'NULLABLE' => false,
            'LENGTH' => '30',
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'groups' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'groups',
            'COLUMN_POSITION' => 5,
            'DATA_TYPE' => 'text',
            'DEFAULT' => null,
            'NULLABLE' => true,
            'LENGTH' => null,
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'access_token' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'access_token',
            'COLUMN_POSITION' => 6,
            'DATA_TYPE' => 'varchar',
            'DEFAULT' => null,
            'NULLABLE' => true,
            'LENGTH' => '255',
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'created' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'created',
            'COLUMN_POSITION' => 7,
            'DATA_TYPE' => 'datetime',
            'DEFAULT' => null,
            'NULLABLE' => false,
            'LENGTH' => null,
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'modified' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'modified',
            'COLUMN_POSITION' => 8,
            'DATA_TYPE' => 'timestamp',
            'DEFAULT' => 'CURRENT_TIMESTAMP',
            'NULLABLE' => false,
            'LENGTH' => null,
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            ),
        'sex' => array(
            'SCHEMA_NAME' => null,
            'TABLE_NAME' => 'user',
            'COLUMN_NAME' => 'sex',
            'COLUMN_POSITION' => 9,
            'DATA_TYPE' => 'int',
            'DEFAULT' => null,
            'NULLABLE' => true,
            'LENGTH' => null,
            'SCALE' => null,
            'PRECISION' => null,
            'UNSIGNED' => null,
            'PRIMARY' => false,
            'PRIMARY_POSITION' => null,
            'IDENTITY' => false
            )
        );

    /**
     * @return UserPeer
     */
    public static function getInstance()
    {
        if (!self::$_instance) {
        	self::$_instance = new UserPeer();
        }
        return self::$_instance;
    }

    /**
     * @return Db_Rowset
     */
    public function findById($id)
    {
        $select = $this->select();
        $select->where('`id` = ?', $id);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByVkId($vk_id)
    {
        $select = $this->select();
        $select->where('`vk_id` = ?', $vk_id);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByName($name)
    {
        $select = $this->select();
        $select->where('`name` = ?', $name);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByLastName($last_name)
    {
        $select = $this->select();
        $select->where('`last_name` = ?', $last_name);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByGroups($groups)
    {
        $select = $this->select();
        $select->where('`groups` = ?', $groups);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByAccessToken($access_token)
    {
        $select = $this->select();
        $select->where('`access_token` = ?', $access_token);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByCreated($created)
    {
        $select = $this->select();
        $select->where('`created` = ?', $created);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findByModified($modified)
    {
        $select = $this->select();
        $select->where('`modified` = ?', $modified);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }

    /**
     * @return Db_Rowset
     */
    public function findBySex($sex)
    {
        $select = $this->select();
        $select->where('`sex` = ?', $sex);
        $rowset = $this->fetchAll($select);
        return $rowset;
    }


}

